package prueba.principal.beans;

import java.io.Serializable;

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;

import javax.faces.model.SelectItem;

public class Idioma  implements Serializable{
	
	private String local="en";
	
	private SelectItem[] idiomas={
		new SelectItem("en", "English"),
		new SelectItem("es","Spanish")
	};

	public SelectItem[] getIdiomas() {
		return idiomas;
	}

	public void setIdiomas(SelectItem[] idiomas) {
		this.idiomas = idiomas;
	}

	public String getLocal() {
		return local;
	}

	public void setLocal(String local) {
		this.local = local;
	}
	
	public String cambioIdioma(String valor){
		this.local=valor;
		return "OK";
	}
	

	public void cambioIdiomaListener(ValueChangeEvent event) {
		
		try{
		
		System.out.println("Cambiamos de idioma.  "+event.getOldValue()+" > "+event.getNewValue());
		
		local=(String) event.getNewValue();
		
	    FacesContext.getCurrentInstance().getExternalContext().redirect("actions/cambioIdioma.jsp?"+local);
	    
	    
	    
		}catch(Exception e){}
		
		
	}
	
	public String refrescar(){
		
		return "refrescar";
		
	}



}
